package com.kyh.common;

/**
 * 函数的通用返回
 * 
 * @author user
 * @date 2018年7月26日
 *
 */
public class RS {
	
	public static int SUCCESS = 1;
	public static int FAILD = 0;

	private int state; // 状态 0-失败 1-成功
	private String msg; // 错误信息

	public int getState() {
		return state;
	}
	public void setState(int state) {
		this.state = state;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	
	public static RS fail() {
		RS commonResp = new RS();
		commonResp.setState(FAILD);
		return commonResp;
	}
	
	public static RS fail(String msg) {
		RS commonResp = new RS();
		commonResp.setState(FAILD);
		commonResp.setMsg(msg);
		return commonResp;
	}
	
	public static RS success() {
		RS commonResp = new RS();
		commonResp.setState(SUCCESS);
		return commonResp;
	}
	
	public static RS success(String msg) {
		RS commonResp = new RS();
		commonResp.setState(SUCCESS);
		commonResp.setMsg(msg);
		return commonResp;
	}
}
